package com.beesphere.products.throttling.processor.async;

import com.beesphere.products.throttling.AsyncCallback;
import com.beesphere.products.throttling.UnitOfWork;

public class DelegateAsyncProcessor implements AsyncProcessor {
    protected AsyncProcessor processor;

    public DelegateAsyncProcessor() {
    }
    public DelegateAsyncProcessor(AsyncProcessor processor) {
        this.processor = processor;
    }

    @Override
    public String toString() {
        return "Delegate(" + processor + ")";
    }

    public AsyncProcessor getProcessor() {
        return processor;
    }

    public void setProcessor(AsyncProcessor processor) {
        this.processor = processor;
    }

    public boolean process (UnitOfWork unitOfWork, long timeout, AsyncCallback callback) {
        return processor.process (unitOfWork, timeout, callback);
    }

    public void process (UnitOfWork unitOfWork) throws Exception {
        AsyncProcessorHelper.process (this, unitOfWork);
    }

    public void start () throws Exception {
    	processor.start ();
    }
    
    public void stop () throws Exception {
    	processor.stop ();
    }

}
